<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>pre-abs账户额度信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
 <div class="Wrapper">
        <div>
           <div id="pageInTab" class="pageInTab">
		   <div tabid="tabA" title="pre-abs账户额度信息" lselected="true">
		<form id="fnc_prj_bsc_info_form" >
             <div class="fieldset1 tabel_col clearFix">
             
             <div class="fieldBox col_50">
                <div class="label">金融机构</div>
                <div class="field">
                    <span id="fncinsNM" name="fncinsNM">&nbsp;${vo.fundRasInsIdNm}</span>
                </div>
                <div style="display: none">
                </div>
             </div>
                             <div class="fieldBox col_50">
                    <div class="label">账户用途</div>
                    <div class="field">
                         <span id="instypeNM" name="instypeNM">&nbsp;${vo.accTypCdNm}</span>                
                </div>
                <div style="display: none">
                </div>
             </div>
             
               <div class="fieldBox col_50">
                    <div class="label">pre-abs账号</div>
	                <div class="field">
	                    <input name="id" id="id" type="hidden"   class="ui-textbox" value="${vo.id}" >
	                  <span >&nbsp;${vo.accNum}</span> 
	                </div>
                </div>  
                <div class="fieldBox col_50">
					<div class="label">可投放款项：</div>
					
					<div class="field">
							 <span >&nbsp;${vo.purpCdsNm}</span> 	
					</div>
				</div>
                
                <div style="display: none">
                	
                </div>
                  
            </div>
            
            
              <div class="btnsBox">
              
               
               <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_3"></i> -->新增额度</span>
            </div>
             <div class="fieldBox col_100">
							<div id="cost1" class="sq-grid">
							</div>
			</div>      
               </div>

         
        </form>
        </div>
             
        </div>
        </div>
    </div>
    
	<script type="text/javascript">
	var grid = null;
	  var pageInApp={
	    		flag:true
	    };
	  var id ='${id}';
	  var selectOrgCd = "";
	   var searchOrgTree = null;
	  var firstNode = null;
	  var textName='${orgTextName}';//节点名称
	  var orgData = null;
		var id ="";//初始值
		var detailFlag = '${detailFlag}';
		var isFlow = '${isFlow}';
	$(function () {
		//$("#clearBtn").hide();
		//$("#addBtn").hide();
		//alert(1);
		//initData();
		show();   
	  //  liger.get("accId").selectValue("${fncPrjBscInfo.accId}"); 
	});
	//初始化数据
	function initData(){
		//	initOrgTree();

		
	//	initcombobox();
		
	//	 initTab();
			$("#fnc_prj_bsc_info_form").ligerForm({
			    validate: true
			});
		//	 var ligerForm = liger.get("fnc_prj_bsc_info_form");
	//	 $("#fnc_prj_bsc_info_form").check_ligerFormEditor();
		
		/*  // 设置业务种类默认为禁用
		    var slt=liger.get("loanTypCd");
            slt.setDisabled();
 */
	
		
		
	
		
	}
	var pageInTab = null;
	  var loadedTabs=[]

	
	 
		function fmoney(s, n)   
		{   
		   n = n > 0 && n <= 20 ? n : 2;   
		   s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";   
		   var l = s.split(".")[0].split("").reverse(),   
		   r = s.split(".")[1];   
		   t = "";   
		   for(i = 0; i < l.length; i ++ )   
		   {   
		      t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");   
		   }   
		   return t.split("").reverse().join("") + "." + r;   
		} 
		
		function show()   
		{   
			 var obj=${vo.id}; //$("#accId").val();
			 if(obj==null || obj==""){
				 top.$.ligerDialog.SQalert({content: "未选择账户或账户已不存在",SQ_type: "warning"});
		         return false; 
			 }
	        
        		f_initCostData1();
        		//$("#clearBtn").show();
        		$("#addBtn").show();
		} 	
		
		
		function f_initCostData1()
	    { 
			
			var id=${vo.id};//$("#limId").val();
	    	$("#cost1").ligerGrid({
	    		url: '<%=path%>/rfbuss/fncpreabslim/initList.do?id='+id,
		    	method : 'get',	 
		    	
		        columns: [
		            { display: '批次号', name: 'batNo', minWidth: 140 ,enabledSort:true},   
		            { display: '可投放事业部', name: 'buOrgCdsNm', minWidth: 140 ,enabledSort:true},
		            { display: '总额度', name: 'preLimAmt', minWidth: 200 ,
		            	render: function (rowdata, rowindex, value, column) { 
		            		
		            		var h='';
		            		if(value&&value!="null"){
		            		    h+=fmoney(value/100.00, 2);
		            		}
		                        return h;
		            		},
	            		
		            	enabledSort:true}, 
		           

		            { display: '剩余额度', name: 'currLimAmt', minWidth: 140 ,
		            	 render: function (rowdata, rowindex, value, column) { 
			            		
			            		var h='';
			            		if(value&&value!="null"){
			            		    h+=fmoney(value/100.00, 2);
			            		}
			                        return h;
			            		},
		            	
		            	enabledSort:true}, 
		            
		            	{ display: '顺序', name: 'payNum', minWidth: 140 ,enabledSort:true},
		            
	        

		            { display: '是否删除', name: 'isdel', minWidth: 80 , enabledSort:true, 
	        		render: function (rowdata, rowindex, value, column) { 
	        			if(value==1){
	        				return "是"
	        			}else{
	        				return "否"
	        			}
	        		
	        		}

		            }, 
		          
	 
		            getOptColumn()
		        ],
		        pageSize:50,
		        root:'rows',
		        record:'total',
		        hideLoadButton : true,
		        width: '100%',
		        height:'100%',
		        heightDiff:-2,
		        checkbox:true,
		        rownumbers:true
		    });
	    	
	    	grid = liger.get("cost1");
	    }
		
	  	//新增

	  	
		function addBtn(){
			var id= ${vo.id};//$("#limId").val();
			$.ligerDialog.SQopen({
	            cls: 'noBorder_Dialog',
	            width: 400,
	            height:320,
	            title : '余额调整',
	            url:'<%=path%>/rfbuss/fncpreabslim/toAddPage.do?id='+id,
	            // 自定义buttons的时候 不要设置 fixButtons: true
	            buttons: [{
	                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                    onclick: function (item, Dialog) {
	                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                        if (Dialog.onOk) {
	                        	Dialog.onOk();
	                        }
	                        setTimeout("show()",1000);
	                        
	                    }
	                }, {
	                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
	                    onclick: function (item, Dialog) {
	                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
	                        if (Dialog.onCancel) Dialog.onCancel();
	                    }
	                }
	            ]
	        });
		}
		function editBtn(id){
			//var id=$("#limId").val();
			//var accno = $("#accId").val();
			$.ligerDialog.SQopen({
	            cls: 'noBorder_Dialog',
	            width: 400,
	            height:320,
	            title : '额度修改',
	            url:'<%=path%>/rfbuss/fncpreabslim/toAddRecPage.do?id='+id,
	            // 自定义buttons的时候 不要设置 fixButtons: true
	            buttons: [{
	                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                    onclick: function (item, Dialog) {
	                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                        if (Dialog.onOk) {
	                        	Dialog.onOk();
	                        }
	                        //grid.reload();
	                        setTimeout("show()",1000);
	                        
	                        
	                    }
	                }, {
	                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
	                    onclick: function (item, Dialog) {
	                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
	                        if (Dialog.onCancel) Dialog.onCancel();
	                    }
	                }
	            ]
	        });
		}
		
		//获取操作列
		function getOptColumn(){
			
			var column = {
	                display: '操作',
	                isSort: false,
	                width: 200,
	                align:'left',
	                render: function (rowdata, rowindex, value){
	                	 var h="";
	               
	                	 if(rowdata.isdel!="1"){
	                	  h='<a class="sq-button-hasicon" href="javascript:editBtn(';
	                      h+="'"+rowdata.id+"'";
	                      h+=')"><i class="sqBtnIco_4"></i>修改剩余额度</a>'
	                      h+='<a class="sq-button-hasicon" href="javascript:removeBtn(';
	                      h+="'"+rowdata.id+"'";
	                      h+=')"><i class="sqBtnIco_7"></i>删除</a>';
	                	 }
	           		
	                	/*   h+='<a class="sq-button-hasicon" href="javascript:commShowFlow(';
	                      h+="'"+rowdata.pInstId+"'";
	                      h+=')"><i class="sqBtnIco_7"></i>查看流程</a>' */
	                    return h;
	                }
	            }
			return column;
			
		}
		
		function removeBtn(id){
			var _ids = [];
				_ids.push(id);
			$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
				if(flag == false)return;
			
				$.ajax({
					type: 'post',
					dataType:'json',
					data:{ids:JSON.stringify(_ids)},
					url: '<%=path%>/rfbuss/fncpreabslim/remove.do?id='+id,
					success:function(msg){
						 if(msg.success == 1){
							 setTimeout("show()",1000);
						 }else{
							 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
						 }
					}
				});
			});
		}
    </script>

</body>
</html>